package de.openkanban.client.ui.presenter;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import com.smartgwt.client.util.SC;

import de.openkanban.client.login.LogIn;

/**
 * Callback that handles die log out request
 */
public class LogOutRequestCallback implements RequestCallback {

	public void onError(Request request, Throwable exception) {
		SC.say("ERROR: " + exception.getMessage());
	}

	public void onResponseReceived(Request request, Response response) {
		if (response.getText().contains("success=true")) {
			LogIn.setLogout();
			LogIn.processLogOut();
		} else {
			SC.say(response.getText());
		}
	}

}
